package world.snowcrystal.commons.service.rpc;

import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.stereotype.Service;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import world.snowcrystal.commons.model.dto.rpc.CheckAccessSignatureRequest;
import world.snowcrystal.commons.model.dto.rpc.RetrieveInvokerRequest;
import world.snowcrystal.commons.model.dto.rpc.SimpleRpcResponse;
import world.snowcrystal.commons.model.entity.User;

@Service
@FeignClient(name = "open-api-platform",path = "/api", contextId = "RpcUserService")
public interface RpcUserService {


    /**
     * 根据 Access Key 获取用户
     *
     * @return 用户 实例，如果不存在该用户，则返回 null
     */
    @PostMapping("/service/user/get-user-by-access-key")
    User getInvoker(@RequestBody RetrieveInvokerRequest request);


    /**
     * 检查给定的 sign 是否是给定用户的 AK/SK 签名
     *
     * @return true 表示签名正确
     */
    @PostMapping("/service/user/check-access-signature")
    SimpleRpcResponse<Boolean> checkAccessSignature(@RequestBody CheckAccessSignatureRequest request);


}
